<div id="form"></div>
<script>
var grid;
var frm=$("#form").ajajform({
	header: "{{!title_edit_category}}",
	submit: {
		url: '/forum/',
		value: "Save",
		ajaj: true,
		params: {mode: "category_save",parent_id: '{{fields.parent_id}}', category_id: '{{fields.category_id}}', ajaj: 1},
	},
	footerButtons: 
	[{value: "delete", click: function() {if (confirm("Are you sure to delete?")) std_response($.ajax({type:"post",url: "/forum/",data:{mode: "delete",ajaj:1,parent_id: '{{fields.parent_id}}', category_id: '{{fields.category_id}}'},async:false}).responseText)} }]
		
	
});

frm.ajajform("insertWidget",null,null,{
	type: "textedit",
	name: "name",
	label: "{{!name}}",
	validate: function(x) {if (!x || x.length==0) return "Empty name";},
	width: 500,
	value: "{{JS:category.name}}"
});

frm.ajajform("insertWidget",null,null,{
	type: "checkbox",
	name: "anon_can_read",
	label: "{{!anon_can_read}}",
	width: 500,
	value: "{{JS:category.anon_can_read}}"
});


frm.ajajform("insertWidget",null,null,{
	type: "select",
	name: "role_read_id",
	label: "{{!role_read_id}}",
	width: 500,
	value: "{{JS:category.role_read_id}}",
	values: {{JSON:roles}}
});

frm.ajajform("insertWidget",null,null,{
	type: "select",
	name: "role_write_id",
	label: "{{!role_write_id}}",
	width: 500,
	value: "{{JS:category.role_write_id}}",
	values: {{JSON:roles}}
});

frm.ajajform("insertWidget",null,null,{
	type: "select",
	name: "role_moder_id",
	label: "{{!role_write_id}}",
	width: 500,
	value: "{{JS:category.role_write_id}}",
	values: {{JSON:roles}}
});


</script>